
// import { removeToken } from '@/utils/storage'
// vuex 用户模块
const state = {
  // 这里的初始值, 也不能为空, 需要从本地的localStorage中拿
  tokenInfo: JSON.parse(localStorage.getItem('tokenInfo')) || {}
}
const mutations = {
  // 设置token
  setTokenInfo (state, tokenObj) {
    state.tokenInfo = tokenObj
    // 一更新token, 就往本地存一份, 本地就可以实时的同步到vuex的数据
    localStorage.setItem('tokenInfo', JSON.stringify(tokenObj))
  },
  // 移除token
  removeToken (state) {
    state.tokenInfo = {} // vuex中的token
    this.removeToken() // 本地的token
  }

}
const getters = {}
const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions
}
